package com.exam.hellohass.adapter;
import java.util.ArrayList;
import java.util.List;
import java.util.zip.Inflater;

import com.exam.hellohass.R;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;


public class ContentListAdapter extends BaseAdapter {

	private List<String> contentList = new ArrayList<String>();
	private LayoutInflater mInflater;
	
	public ContentListAdapter(Context context , List<String> contentList) {
		this.contentList = contentList;
		mInflater = LayoutInflater.from(context);
	}
	
	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return contentList.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return contentList.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View coverView, ViewGroup viewGroups) {
		ViewHolder viewHolder;
		if (coverView == null) {
			viewHolder = new ViewHolder();
			coverView = mInflater.inflate(R.layout.contentlist_item, null);
			viewHolder.contentText = (TextView) coverView.findViewById(R.id.content_list_textView);
			coverView.setTag(viewHolder);
		}else {
			viewHolder = (ViewHolder) coverView.getTag();
		}
		viewHolder.contentText.setText(contentList.get(position));
		return coverView;
	}
	
	class ViewHolder{
		public TextView contentText;
	}

}
